package edu.kjxy.worker0312;

import java.util.Scanner;

public class worker10 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long num = in.nextLong();
		int sum = 0, ret = 1;
		while(num > 0) {
			long bit = num % 10;
			sum += ret * bit;
			ret *= 2;
			num /= 10;
		}
		System.out.println(sum);
		in.close();
	}

}
